package com.hant;

import com.hant.shopserivce.api.service.order.RpcShopOrderService;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.CountDownLatch;

/**
 * dubbo 服务提供方
 * @author raysonfang
 * @公众号 Java技术干货（ID:raysonfang）
 */
@SpringBootApplication
@EnableDubbo
@RestController
public class ShopServiceUserApplication {

    @Reference(loadbalance = "roundrobin")
    RpcShopOrderService shopOrderService;

    /*@Reference
    RpcShopUserService shopUserService;
*/
    @RequestMapping(name = "/queryOrder", method = RequestMethod.GET)
    public String queryOrder(){
        return shopOrderService.queryOrder("--user query order");
    }

    /*@RequestMapping(name = "/queryUser", method = RequestMethod.GET)
    public String queryUser(){
        return shopUserService.queryUser("query user");
    }
*/
    //使用jar方式打包的启动方式
    private static CountDownLatch countDownLatch = new CountDownLatch(1);
    public static void main(String[] args) throws InterruptedException{
        SpringApplication.run(ShopServiceUserApplication.class, args).registerShutdownHook();
        countDownLatch.await();
    }
}
